/********************************************************************************
 Manuscript: The Implications of Cohabitation Between Working Age Children  
 and Parents on Political Opinions
 Author: Alexandra Jabbour
 Journal: EJPR
 
 
 Dofile Name: master.do
 Created: March 2023
 Purpose: replicate the figures and tables from MS and appendices 
 Stata: version 16.0
 Software: MacOS Monterey 12.4
*******************************************************************************/

	clear all
	set more off
	numlabel, add
	
	set scheme lean1
	
	* Install packages if needed 
	
	*ssc install estout, replace all 
	*ssc install blindschemes, replace all
	*ssc install nrow, replace all
	*ssc install coefplot, replace all 
	
/*******************************************************************************
	PART 0: Select sections to run (1 to run 0 otherwise)
*******************************************************************************/
	* Preparation 
	local paths			0 

	* Main analysis
	local main_children 0 // produce Figure 1 in MS, Appendix H and Appendix I
	local main_parents	0 // produce Figure 3 in MS, Appendix L
	
	* Appendix 
	local country_study 0 // produce Table 1 in Appendix D 
	local countrygraph  0 // produce Figure 1 in Appendix O
	local age           0 // produce Figure 2 in MS
	local trend 		0 // produce Figure 1 in Appendix A
	local unemployment  0 // produce Figure in Appendix B
	local variables 	0 // produce Table 1 in Appendix E 
	local correlation   0 // produce Figures 1 and 2 in Appendix F 
	local fdr		    0 // produce Tables 1 in Appendix Q & R
	local partisanship  0 // produce tables in appendix M,N,J,K
	local cutoff        0 // produce Table 1 in Appendix P
	local gender        0 // produce Tables 1 in appendix S & T
	
/*******************************************************************************
	PART 1: Set folder paths
			
*******************************************************************************/

	if `paths' {
		
	*Set your directory:
	
		*Current paths are the author's paths, change paths to fit your own 
	
	global directory "~/Dropbox/replication_cohabitation_jabbour"

	* windows directory
		* You need to create four folders: 
			* - data
			* - dofiles
			* - tables 
			* - figures
		
	global data "${directory}/data" // Where the datasets should be located 
	global dofiles "${directory}/dofiles" // Where the dofiles should be located 
	global tables "${directory}/tables" // Where the tables will be stored  
	global figures "${directory}/figures" // Where the figures will be stored  
	
	}

	
/*******************************************************************************
	PART 2: regression - main results 
*******************************************************************************/

	if `main_children'{
		cd "${dofiles}" 
		do main_results_children.do 
	}
	
	if `main_parents' {
		cd "${dofiles}" 
		do main_results_parents.do
	}
		
	if `countrygraph' {
		cd "${dofiles}" 
		do countrygraph.do 
	}
		
/*******************************************************************************
	PART 3: descriptive statistics
*******************************************************************************/
	
	
	if `age' {		
		cd "${dofiles}"	
		do age_distribution.do 
	}
	
	if `trend' {
		cd "${dofiles}"
		do cohabitation_trend.do
	}
	
	if `unemployment'{
		cd "${dofiles}"
		do unemployment.do
	}
				
	if `country_study' {				
		cd "${dofiles}"		
		do country_study.do 	
	}	
	
	if `variables' {				
		cd "${dofiles}"		
		do variables.do	
	}	
		
	if `correlation' {
		cd "${dofiles}"		
		do correlation_dv.do
	}
	
	
/*******************************************************************************
	PART 4: False Discovery Rate
*******************************************************************************/
	
	if `fdr' {
		cd "${dofiles}"
		do fdr.do 
	}
	
/*******************************************************************************
	PART 5: Incumbent Rob-test
*******************************************************************************/
	
	
	if `partisanship' {
	
	* Produce Table 1 in Appendix M
	* Parents hypothesis controlling for incumbent partisanship (binary variable)
		cd "${dofiles}"	
		do parents_incumbent_binary.do 
	
	* Produce Table 1 in Appendix N
	* Parents hypothesis controlling for incumbent partisanship (3 cat.)
		cd "${dofiles}"	
		do parents_incumbent_categorical.do 
	
	* Produce Table 1 in Appendix J
	* Children hypothesis controlling for incumbent partisanship (binary variable)
		cd "${dofiles}"	
		do children_incumbent_binary.do 
	
	* Produce Table 1 in Appendix K
	* Children hypothesis controlling for incumbent partisanship (3 cat.)
		cd "${dofiles}"	
		do children_incumbent_categorical.do 	
	
	}	
	
/*******************************************************************************
	PART 6: cut-off age
*******************************************************************************/
		
	if `cutoff' {
		* Parents hypothesis - cohabitation with 25 to 34 years old 
		cd "${dofiles}"	
		do parents_2534_cutoff.do
	}

/*******************************************************************************
	PART 7: Parents hypohtesis (Gender)
*******************************************************************************/
		
	if `gender' {
		* Parents hypothesis - gender (as a control variable or moderator)
		cd "${dofiles}" 
		do gender_parents.do	
	}
		
					******* THE END *******
	
